home *** CD-ROM | disk | FTP | other *** search
Text File | 2002-10-16 | 32.0 KB | 1,010 lines |
- # Common rules for making SGML, DocBook XML and HTML
- #
- # File organization
- # 1. Initialize variables and constants
- # 2. Rules for specific file types
- # 3. Rules to build a single book SGML file
- # 4. Rules to transform SGML into XML
- # 5. Rules to transform XML into HTML
- # 6. Install and IDB rules
- # 7. Clean up rules
- # 8. Figure rules
- # 9. Misc. rules
-
- ##############################################################
- #
- # Section #1 - Initialization
- #
- ##############################################################
-
- # BOOK_FILES is defined when it's an SGML book...
- #if defined(BOOK_FILES)
- SOURCES = ${BOOK_FILES}
- TMP_TARGETS = ${BOOK_FILES:.doc=.sgm}
- TARGETS = ${TMP_TARGETS:.fm=.sgm}
-
- TMP_XXX_FILES = ${BOOK_FILES:S/.doc$/.sgm/g}
- XXX_FILES = ${TMP_XXX_FILES:S/.fm$/.sgm/g}
- SGM_FILES = ${XXX_FILES:S/.mif$/.sgm/g}
- ERR_FILES = ${SGM_FILES:S/.sgm$/.err/g}
- DIRT_FILES = booklist.txt
-
- TMP_MIF_FILES = ${BOOK_FILES:S/.doc$/.mif/g}
- MIF_FILES = ${TMP_MIF_FILES:S/.fm$/.mif/g}
- TMP_BACKUP_FILES = ${BOOK_FILES:S/.doc$/.backup.doc/g}
- BACKUP_FILES = ${TMP_BACKUP_FILES:S/.fm$/.backup.fm/g}
-
- #if ${BOOK_FILES:S/[ ]*/ /g} == "${MIF_FILES}"
- MIF_FILES =
- #endif
- #endif
-
- #if defined(BOOK_FILES) && ${BOOK_FILES} == "book.sgm" && ${DTD} == "SGIDOCBK"
- PARSE_SGML = TRUE
- SGM_FILES != ls book.sgm *.sgml | grep -v ${MASTER_SGM}
- MIF_FILES =
- ERR_FILES =
- #endif
-
- SHELF != echo ${BOOKSHELF} | sed "s/.*\///"
- LANG_ID != echo ${BOOK_LANG} | sed "s/_.*//" | tr "[a-z]" "[A-Z]" | sed "s/JA/JP/" | sed "s/C/EN/"
- DOCTYPE = '<!DOCTYPE SGIDOCBK PUBLIC "-//Silicon Graphics, Inc.//DTD DocBook V2.3-based Subset V1.5//${LANG_ID}" [ ]>'
-
- LANGUAGE != echo ${LANG_ID} | tr "[A-Z]" "[a-z]" | sed "s/jp/ja/"
- MKBOOK_FLAGS = -language ${LANGUAGE}
-
- FULL_TITLE_ENCODED != echo ${FULL_TITLE} | sed -e 's/\&/\&/g' -e 's/"/\"/g' -e "s/'/\'/g" -e "s/</\</g" -e "s/>/\>/g" | perl -p -e 's/([\x80-\xFF])/sprintf("&\#x%lx;", ord($$1))/ge'
- PARTNUMBER != echo ${VERSION} | sed -e 's/[, ].*$$//'
- DOCBOOK_OVERRIDE = prod/${PARTNUMBER}.docbook.xml
- DEFAULT_PDF = prod/${PARTNUMBER}.pdf
-
- XSLT_PARAMS =
-
- #if defined(CHUNK_SECTION_DEPTH)
- XSLT_PARAMS = --param chunk.section.depth ${CHUNK_SECTION_DEPTH}
- #elif ${SHELF} == "Help"
- XSLT_PARAMS = --param chunk.section.depth 1
- #endif
-
- #if make(review)
- REVIEW = -draft
- XSLT_PARAMS += --param show.comments 1
- #endif
-
- #if ${NUMBERED_HEADS} == "Y"
- XSLT_PARAMS += --param section.autolabel 1 --param section.label.includes.component.label 1
- #endif
-
- #if defined(LOCAL_HTML_XSLT)
- HTML_XSLT = ../../${LOCAL_HTML_XSLT}
- #elif exists(xslt/main-html.xsl)
- HTML_XSLT = ../../xslt/main-html.xsl
- #else
- HTML_XSLT = ../xslt/sgi/sgi-html-chunk.xsl
- #endif
-
- # all the definitions based on the specific DTD in the Makefile
- #if ${DTD} == "SGIDOCBK"
- REAL_DTD = ${SGIDOCBK_LIB}/dtd/default.dtd
- STYLES_DIR = ${SGIDOCBK_LIB}/styles
- HIDDEN ?= FALSE
-
- #elif ${DTD} == "SGIDOC"
- REAL_DTD = ${SGIDOC_LIB}/dtd/default.dtd
- STYLES_DIR = ${SGIDOC_LIB}/styles
- HIDDEN ?= FALSE
-
- #elif ${DTD} == "XHELP"
- REAL_DTD = ${XHELP_LIB}/dtd/XHELP.dtd
- STYLES_DIR = ${XHELP_LIB}/styles
- HIDDEN ?= TRUE
-
- #elif ${DTD} == "DOCBOOK"
- REAL_DTD = ${DOCBOOK_LIB}/dtd/docbook.dtd
- STYLES_DIR = ${DOCBOOK_LIB}/styles
- HIDDEN ?= FALSE
-
- #else
- REAL_DTD = ../../${BOOK}.dtd
- STYLES_DIR = ../../styles
- #endif
-
- # XXX Problem with multi-byte locales and bob index generation.
- # XXX This capability is disabled.
- #
-
- # Default encoding values
- XML_ENCODING = ISO-8859-1
- HTML_ENCODING = ISO-8859-1
- HTML_CHARSET = ISO-8859-1
-
- # Used to redirect to an L10N specific set of entities
- SGML2XML_L10N = -public '-//Silicon Graphics, Inc.//XML L10N Entity DTD V1.0//EN' -system 'dtd/entity-dtd/l10n-entity.dtd'
-
- #if ${BOOK_LANG} == "C"
-
- #elif ${BOOK_LANG} == "de"
-
- #elif ${BOOK_LANG} == "fr"
-
- #elif ${BOOK_LANG} == "es"
-
- #elif ${BOOK_LANG} == "ja_JP.EUC"
- XML_ENCODING = eucJP
- HTML_ENCODING = eucJP
- HTML_CHARSET = euc-jp
- NO_BOB_INDEX = TRUE
- NO_SGSEARCH = TRUE
- SGML2XML_ARGS = ${SGML2XML_L10N}
-
- #elif ${BOOK_LANG} == "ja_JP.SJIS"
- XML_ENCODING = sjis
- HTML_ENCODING = eucJP
- HTML_CHARSET = euc-jp
- NO_BOB_INDEX = TRUE
- NO_SGSEARCH = TRUE
- SGML2XML_ARGS = ${SGML2XML_L10N}
-
- #elif ${BOOK_LANG} == "ko_KR.euc"
- XML_ENCODING = eucKR
- HTML_ENCODING = eucKR
- HTML_CHARSET = euc-kr
- NO_BOB_INDEX = TRUE
- NO_SGSEARCH = TRUE
- SGML2XML_ARGS = ${SGML2XML_L10N}
-
- #elif ${BOOK_LANG} == "zh_CN.ugb"
- XML_ENCODING = gbk
- HTML_ENCODING = gbk
- HTML_CHARSET = gb2312
- NO_BOB_INDEX = TRUE
- NO_SGSEARCH = TRUE
- SGML2XML_ARGS = ${SGML2XML_L10N}
-
- #elif ${BOOK_LANG} == "zh_CN.gbk"
- XML_ENCODING = gbk
- HTML_ENCODING = gbk
- HTML_CHARSET = gb2312
- NO_BOB_INDEX = TRUE
- NO_SGSEARCH = TRUE
- SGML2XML_ARGS = ${SGML2XML_L10N}
-
- #elif ${BOOK_LANG} == "zh_TW.ucns"
- XML_ENCODING = eucTW
- HTML_ENCODING = eucTW
- HTML_CHARSET = x-euc-tw
- NO_BOB_INDEX = TRUE
- NO_SGSEARCH = TRUE
- SGML2XML_ARGS = ${SGML2XML_L10N}
-
- #elif ${BOOK_LANG} == "zh_TW.big5"
- XML_ENCODING = big5
- HTML_ENCODING = big5
- HTML_CHARSET = big5
- NO_BOB_INDEX = TRUE
- NO_SGSEARCH = TRUE
- SGML2XML_ARGS = ${SGML2XML_L10N}
-
- #else
- INVALID_LANG = "TRUE"
- #endif
-
- ##############################################################
- #
- # Section #2 - File type conversion rules
- #
- ##############################################################
-
- .SUFFIXES: .sgm .doc .fm .mif .err
-
- ## Rule for converting Frame files to MIF files
- ## if not SGIDOC DTD then don't use the conditional file
- .fm.mif .doc.mif:
- #if ${DTD} == "SGIDOC" || ${DTD} == "SGIDOCBK"
- @TMPFILE=${TMPDIR}/${@:.mif=.$$.tmp}; \
- TMP_CONDITION_FILE=${TMPDIR}/${@:.mif=.$$.cond.tmp}; \
- echo "system \"cp ${CONDITION_FILE} $${TMP_CONDITION_FILE}\"" > $${TMPFILE}; \
- echo "system \"chmod 664 $${TMP_CONDITION_FILE}\"" >> $${TMPFILE}; \
- echo "Open $<" >> $${TMPFILE}; \
- echo "Open $${TMP_CONDITION_FILE}" >> $${TMPFILE}; \
- echo "UseFormatsFrom x $< $${TMP_CONDITION_FILE}" >> $${TMPFILE}; \
- echo "SaveAs m $< $*.mif" >> $${TMPFILE}; \
- echo "Quit $<" >> $${TMPFILE}; \
- ${FMBATCH} $${TMPFILE}; \
- ${RM} -f $${TMPFILE} $${TMP_CONDITION_FILE}
- #else
- @TMPFILE=${TMPDIR}/${@:.mif=.$$.tmp}; \
- echo "Open $<" > $${TMPFILE}; \
- echo "SaveAs m $< $*.mif" >> $${TMPFILE}; \
- echo "Quit $<" >> $${TMPFILE}; \
- ${FMBATCH} $${TMPFILE}; \
- ${RM} -f $${TMPFILE}
- #endif
-
- # Rule for converting MIF files to SGML files
- # this also builds CGM figures if necessary
- .mif.sgm:
- #if ${DTD} == "SGIDOCBK"
- @${MIF2SGIDOCBK} ${CGM_NOTRAS} $<
- #elif ${DTD} == "SGIDOC"
- #if defined(BOOK_LANG)
- @${MIF2SGML} ${CGM_NOTRAS} -i ${INTL_MAP_DIR}/${BOOK_LANG}.intl_map $<
- #else
- @${MIF2SGML} ${CGM_NOTRAS} $<
- #endif
- #elif ${DTD} == "XHELP"
- @echo "Frame to XHELP not supported at this time"; exit 1
- #elif ${DTD} == "DOCBOOK"
- @echo "Generic Frame to DocBook requires Passage's translator"; exit 1
- #else
- ${OTHER_TRANSLATOR} $<
- #endif
- -@ mkdir -p online 1> /dev/null 2>&1
- @if (`grep 'RASTERCONVERT' $*.sgm>/dev/null`) then \
- echo "Creating CGM images..."; \
- (CLHOME=${CLHOME}; MIFTOCGM_IP=${MIFTOCGM_IP}; \
- export CLHOME MIFTOCGM_IP; \
- ${MIFTOCGM} ${CGM_VERBOSE} -c ${CLHOME}/data/kt.map -i $< -o online/$*.cgm ); \
- TIFF_FILES=`grep '<!-- RASTERCONVERT:' $*.sgm |sed -e 's/.*<!-- RASTERCONVERT: \(.*\) -->.*/\1/'` ; \
- for i in $${TIFF_FILES} ; do \
- echo "Converting" $$i "to GIF"; \
- N_GIF=`echo $$i|sed 's/\.cgm$$/-1.gif/'|sed 's/\.cgm\([0-9][0-9]*\)/-\1\.gif/'`; \
- (CLHOME=${CLHOME}; export CLHOME; \
- ${CLTRANS} online/$$i online/$$i.out -of tiff \
- ${CGM_VERBOSE} \
- -oo "${CGM_VERBOSE} -t palette -comp lzw -dpi 285"); \
- ( LD_LIBRARY_PATH=${TOOLROOT}/usr/lib32/internal; export LD_LIBRARY_PATH; \
- ${TIFFTOPNM} online/$$i.out | ${PNMSCALE} .37 | ${PNMCROP} | \
- ${PNMMARGIN} -white 10 | \
- ${PPMQUANT} 256 > ${TMPDIR}/$$i.ppm; \
- /usr/sbin/fromppm ${TMPDIR}/$$i.ppm ${TMPDIR}/$$i.rgb; \
- /usr/sbin/hipass3 ${TMPDIR}/$$i.rgb ${TMPDIR}/$$i.rgb_sh .5; \
- ${TOGIF} ${TMPDIR}/$$i.rgb_sh online/$${N_GIF} -u ) ; \
- ${RM} -f online/$$i.out online/$$i ${TMPDIR}/$$i.ppm ${TMPDIR}/$$i.rgb ${TMPDIR}/$$i.rgb_sh; \
- done; \
- fi
-
- # Rule for generating UNKNOWN errors report files for SGML files
- .sgm.err:
- -@${EGREP} '<\!\-\- ERROR|<\!\-\- WARNING|<UNKNOWN.ERROR' $< > $*.err
-
- EndPart:
- @echo "</PART>" > EndPart
-
- EndPart.err:
- @touch EndPart.err
-
- ##############################################################
- #
- # Section #3 - Rules to build a single, whole-book SGML file
- #
- ##############################################################
-
- # Build the master SGML file which is concatenation of all individual
- # SGML files with TITLE at the front and <SGIDOCBK> tag around
- # the <BOOK> and individual chapter content.
- #
- # OR parse the book.sgm file to generate the master SGML file
-
- ${MASTER_SGM}: ${SGM_FILES}
- #if defined(INVALID_LANG)
- @echo "WARNING: ${BOOK_LANG} is an unsupported LANG value. Supported values are:"
- @echo " C, de, fr, es, ja_JP.EUC, ja_JP.SJIS, ko_KR.euc, zh_CN.ugb,"
- @echo " zh_CN.gbk, zh_TW.ucns, and zh_TW.big5."
- #endif
- @echo " ======== Building master sgml file ======== "
- @${RM} -f ${MASTER_SGM}
- @if [ "${SGM_FILES}" = "" ] ; then \
- echo "error: No SGML files to process"; \
- exit 1; \
- fi
- @${RM} -f ${TMP_MASTER_SGM}
- @${RM} -f ${INDEXFILE}
- #if defined(PARSE_SGML)
- @${RM} -f bobindex.idx
- @${SPAM} -c ${CATALOG} -r -mms -x -x ${BOOK_FILES} > ${TMP_MASTER_SGM}
- @${MAKE_BLDSGML} $(REVIEW) -I${TMP_MASTER_SGM} -O${MASTER_SGM}
- #if make(install)
- @${RM} -f ${TMP_MASTER_SGM}
- @${MV} ${MASTER_SGM} ${TMP_MASTER_SGM}
- @${XFORM_SGML} -I${TMP_MASTER_SGM} -O${MASTER_SGM}
- #endif
- @${RM} -f ${TMP_MASTER_SGM}
- #else
- #if ${DTD} == "SGIDOC" || ${DTD} == "SGIDOCBK"
- #if ! defined(NO_BOB_INDEX)
- @for i in ${SGM_FILES}; do cat $$i >> ${TMP_MASTER_SGM}; done
- #if ${DTD} == "SGIDOC"
- @cat ${TMP_MASTER_SGM} | ${INDEXGEN} -s -o ${INDEXFILE}
- #else
- @${INDEXGENDB} -i ${TMP_MASTER_SGM} -s -o ${INDEXFILE}
- #endif
- #endif
- #if ${DTD} == "SGIDOC"
- @if [ "${DOC_TYPE}" = "" ] ; then \
- echo "<SGIDOC LANG=\"${BOOK_LANG}\"><MANUAL>" > ${MASTER_SGM}; \
- else \
- echo "<SGIDOC LANG=\"${BOOK_LANG}\"><${DOC_TYPE}>" > ${MASTER_SGM}; \
- fi
- #else
- @echo ${DOCTYPE} > ${MASTER_SGM}
- #if ${NUMBERED_HEADS} == "Y"
- @echo "<SGIDOCBK LANG=\"${BOOK_LANG}\" NUMHEADS=\"Y\"><BOOK>" >> ${MASTER_SGM}
- #else
- @echo "<SGIDOCBK LANG=\"${BOOK_LANG}\" NUMHEADS=\"N\"><BOOK>" >> ${MASTER_SGM}
- #endif
- #endif
- #endif
- #if ! defined(NO_BOB_INDEX) && ${DTD} == "SGIDOCBK"
- @cat ${TMP_MASTER_SGM} >> ${MASTER_SGM}
- #else
- @for i in ${SGM_FILES}; do cat $$i >> ${MASTER_SGM}; done
- #endif
- #if ${DTD} == "SGIDOC" || ${DTD} == "SGIDOCBK"
- #if ! defined(NO_BOB_INDEX)
- @cat ${INDEXFILE} >> ${MASTER_SGM}
- #endif
- #if ${DTD} == "SGIDOC"
- @if [ "${DOC_TYPE}" = "" ] ; then \
- echo "</MANUAL></SGIDOC>" >> ${MASTER_SGM} ; \
- else \
- echo "</${DOC_TYPE}></SGIDOC>" >> ${MASTER_SGM} ; \
- fi
- #else
- @echo "</BOOK></SGIDOCBK>" >> ${MASTER_SGM}
- #endif
- #if make(install)
- @${RM} -f ${TMP_MASTER_SGM}
- @${MV} ${MASTER_SGM} ${TMP_MASTER_SGM}
- @${XFORM_SGML} -I${TMP_MASTER_SGM} -O${MASTER_SGM}
- #endif
- @${RM} -f ${TMP_MASTER_SGM}
- #endif
- #endif
- #if defined(BOOK_FILTER) && exists(${BOOK_FILTER})
- @${BOOK_FILTER} ${MASTER_SGM} > ${MASTER_SGM}.new
- @${MV} ${MASTER_SGM}.new ${MASTER_SGM}
- #endif
-
- ##############################################################
- #
- # Section #4 - SGML to DocBook XML conversion rules
- #
- ##############################################################
-
- prep_build: build/.placeholder
-
- build/.placeholder: Makefile
- @echo "=============================================="
- @echo "Setting up the build directory"
- @echo "=============================================="
- @mkdir -p build/sgi_html
- @rm -f build/dtd build/ent
- @ln -s ${XML_DTD} build
- @if [ -d ent.xml ] ; then \
- ln -s ent.xml build/ent ; \
- else \
- ln -s ${XML_ENTS} build/ent ; \
- fi
- @rm -rf build/xslt
- @mkdir -p build/xslt
- @ln -s ${XSLT_STYLES}/docbook-xsl build/xslt/docbook-xsl
- @ln -s ${XSLT_STYLES}/sgi build/xslt/sgi
- @ln -s ${XSLT_STYLES}/conversion build/xslt/conversion
- @touch build/.placeholder
-
-
- ${MASTER_XML}: ${MASTER_SGM}
- @echo "=============================================="
- @echo "Transforming SGML to XML"
- @echo "=============================================="
- @mkdir -p build
- @${SGML2XML} $(SGML2XML_ARGS) -nocomments -doctype ${DTD} \
- -encoding ${XML_ENCODING} ${MASTER_SGM} ${MASTER_XML}
-
- docbook.xml: build/docbook.xml
-
- #if exists(${DOCBOOK_OVERRIDE})
- build/docbook.xml: ${DOCBOOK_OVERRIDE} build/.placeholder
- ## check if the link exists since make will always recreate it
- @echo "================================================================="
- @echo "Copying the existing ${DOCBOOK_OVERRIDE} XML file"
- @echo "================================================================="
- rm -f build/docbook.xml
- cp ${DOCBOOK_OVERRIDE} build/docbook.xml
- #elif ${DTD} == "DOCBOOK_XML"
- build/docbook.xml: ${BOOK_FILES} build/.placeholder
- ## TODO: adjust dependencies and clean rules for DocBook XML books
- @echo "=============================================="
- @echo "Parsing the ${BOOK_FILES} DocBook XML file"
- @echo "=============================================="
- @${RM} -f build/docbook.xml dtd
- @ln -s ${XML_DTD} dtd
- @( LD_LIBRARY_PATH=${XMLLIBS}; export LD_LIBRARY_PATH; \
- ${XMLLINT} --timing --valid --noent -o build/docbook.xml ${BOOK_FILES} 2>&1 | tee build/xmllint.log )
- @${RM} -f build/xmllint.errs
- -@grep -i 'error' build/xmllint.log > build/xmllint.errs
- @if [ -s build/xmllint.errs ] ; then \
- echo " " ; \
- echo "DocBook DTD Validity Errors" ; \
- echo "The errors shown above must be corrected." ; \
- echo " " ; \
- ${RM} -f build/docbook.xml ; \
- exit 1 ; \
- fi
- @perl -pi -e 's/fileref\s*=\s*"online\//fileref="figures\//g' build/docbook.xml
- #else
- build/docbook.xml: ${MASTER_SGM} build/.placeholder
- @echo "=============================================="
- @echo "Transforming SGML to XML"
- @echo "=============================================="
- @${RM} -f build/docbook.xml
- @${SGML2XML} $(SGML2XML_ARGS) -nocomments -doctype ${DTD} \
- -encoding ${XML_ENCODING} ${MASTER_SGM} ${MASTER_XML}
- @echo "=============================================="
- @echo "Transforming ${DTD} XML to DocBook XML"
- @echo "=============================================="
- #if ${DTD} == "SGIDOCBK"
- @( LD_LIBRARY_PATH=${XMLLIBS}; export LD_LIBRARY_PATH; ${XSLTPROC} --timing --param makefile.title "'${FULL_TITLE_ENCODED}'" -o ${DOCBOOK_XML} build/xslt/conversion/sgidocbk2docbook.xsl ${MASTER_XML} )
- #elif ${DTD} == "SGIDOC"
- @( LD_LIBRARY_PATH=${XMLLIBS}; export LD_LIBRARY_PATH; ${XSLTPROC} --timing --param makefile.title "'${FULL_TITLE_ENCODED}'" -o ${DOCBOOK_XML} build/xslt/conversion/sgidoc2docbook.xsl ${MASTER_XML} )
- #elif ${DTD} == "DOCBOOK"
- @${CP} ${MASTER_XML} ${DOCBOOK_XML}
- #elif ${DTD} == "CRAYDOCBK"
- @( LD_LIBRARY_PATH=${XMLLIBS}; export LD_LIBRARY_PATH; ${XSLTPROC} --timing -o ${DOCBOOK_XML} build/xslt/conversion/craydocbk2docbook.xsl ${MASTER_XML} )
- #else
- @echo " "
- @echo "The ${DTD} DTD is unsupported for automatic XML conversion."
- @echo "You can convert the ${MASTER_SGM} file to DocBook XML"
- @echo "and save the new file as 'prod/docbook.xml' where it"
- @echo "will be used automatically."
- @echo " "
- @exit 1
- #endif
- ## @${RM} -f ${MASTER_XML}
- #endif
-
- ##############################################################
- #
- # Section #5 - XML to HTML conversion rules
- #
- ##############################################################
-
- .ORDER: docbook.html sgi_data/index.wrd.gz xmlbook_install
-
- docbook.html: build/sgi_html/index.html
-
- build/sgi_html/index.html: build/docbook.xml
- @echo "=============================================="
- @echo "Transforming DocBook XML to HTML"
- @echo "=============================================="
- @mkdir -p build/sgi_html
- @${RM} -f build/sgi_html/*.html build/sgi_html/*.xml
- @( cd build/sgi_html; LD_LIBRARY_PATH=${XMLLIBS}; export LD_LIBRARY_PATH; \
- ${XSLTPROC} --timing ${XSLT_PARAMS} \
- --param default.encoding "'${HTML_ENCODING}'" \
- -o junk.html ${HTML_XSLT} ../docbook.xml 2>&1 | \
- tee ../xsltproc.log )
- @if [ -a build/sgi_html/junk.html ] ; then \
- echo " " ; \
- echo "FATAL ERROR:" ; \
- echo "The XSLT stylesheets incorrectly produced extra HTML" ; \
- echo "output in the build/sgi_html/junk.html file. The cause" ; \
- echo "of the problem needs to be investigated." ; \
- echo " " ; \
- exit 1 ; \
- fi
- @if [ ! -f build/sgi_html/index.html ] ; then \
- echo " " ; \
- echo "The HTML generation phase was not successful" ; \
- echo "since an index.html was not created." ; \
- echo " " ; \
- exit 1 ; \
- fi
- @if [ -f build/sgi_html/index.html -a "${HTML_ENCODING}" != "${HTML_CHARSET}" ] ; then \
- echo "=========================================================" ; \
- echo "Switching HTML charset from ${HTML_ENCODING} to ${HTML_CHARSET}" ; \
- echo "=========================================================" ; \
- perl -pi -e 's/(<meta.*?charset=)${HTML_ENCODING}/\1${HTML_CHARSET}/i' build/sgi_html/*.html ; \
- fi
- @if [ -f build/sgi_html/toc.xml ] ; then \
- echo "==============================================" ; \
- echo "Post-processing XML TOC file" ; \
- echo "==============================================" ; \
- mkdir -p build/sgi_data ; \
- rm -f build/sgi_data/toc.xml ; \
- mv build/sgi_html/toc.xml build/sgi_data ; \
- ( LD_LIBRARY_PATH=${XMLLIBS}; export LD_LIBRARY_PATH; \
- ${XSLTPROC} -o build/sgi_data/${BOOK}.toc \
- build/xslt/sgi/sgi-tpl-toc.xsl build/sgi_data/toc.xml ) ; \
- fi
- @echo " "
- @echo "For review:"
- @echo "file://`pwd`/build/sgi_html/index.html"
- @echo " "
-
- #if ${DTD} != "HTML"
- html_files: build/sgi_html/index.html
- #else
- html_files: htmlbook
- #endif
-
- build/redirect.html metadata: booklist.txt _force
- @echo "=============================================="
- @echo "Creating fulltext index, OMF and redirect file"
- @echo "=============================================="
- @mkdir -p build/sgi_data
- # Generate the fulltext index
- #if ! defined(NO_SGSEARCH)
- @if [ -d build/sgi_html ] ; then \
- ( cd build ; ln -s ../booklist.txt . ; ${DTL2SGFT} -f -l -b ${BOOK} -s . ; rm -f booklist.txt ) ; \
- fi
- #endif
- # Generate a new OMF metadata file
- @${RM} -f build/*.omf
- @${SGI2OMF} -pth . ${BOOK} > /dev/null
- @${MV} ${BOOK}*.omf build/sgi_data
- # Create a redirection HTML file for use by InSight
- @${RM} -f build/redirect.html
- @echo '<html>' > build/redirect.html
- @echo '<head><title>${BOOK} Redirection</title>' >> build/redirect.html
- @if [ -f build/sgi_html/index.html ] ; then \
- echo '<META HTTP-EQUIV=REFRESH CONTENT="0; URL=sgi_html/index.html">' >> build/redirect.html ; \
- elif [ -d build/sgi_html ] ; then \
- echo '<META HTTP-EQUIV=REFRESH CONTENT="0; URL=sgi_html/">' >> build/redirect.html ; \
- elif [ -d build/pdf ] ; then \
- echo '<META HTTP-EQUIV=REFRESH CONTENT="0; URL=pdf/">' >> build/redirect.html ; \
- fi ;
- @echo '</head>' >> build/redirect.html
- @echo '<body bgcolor="#FFFFFF">' >> build/redirect.html
- @if [ -f build/sgi_html/index.html ] ; then \
- echo '<a href="sgi_html/index.html">Redirection Link</a>' >> build/redirect.html ; \
- elif [ -d build/sgi_html ] ; then \
- echo '<a href="sgi_html/">Redirection Link</a>' >> build/redirect.html ; \
- elif [ -d build/pdf ] ; then \
- echo '<a href="pdf/">Redirection Link</a>' >> build/redirect.html ; \
- else \
- echo '<p>This book has no content.</p>' >> build/redirect.html ; \
- fi ;
- @echo '</body></html>' >> build/redirect.html
-
- booklist.txt: Makefile
- @echo "=============================================="
- @echo "Creating booklist.txt file"
- @echo "=============================================="
- #if ${DTD} != "OTHER"
- @if [ -f booklist.txt ] ; then \
- ${MV} booklist.txt booklist.txt.old; \
- fi
- @echo '<BOOK NAME="${TITLE}" ALIAS="'${FULL_TITLE}'" SGITYPE="sgi_html" SGIVERSION="${VERSION}" SGIBKADDR="${FEEDBACK_ADDR}" SGIGROUP="HTML">' > booklist.txt
- #endif
-
- ##############################################################
- #
- # Section #6 - Install and Packaging rules
- #
- ##############################################################
-
- # dummy rule to force a target to be built
- _force:
-
- #if ${DTD} == "PDF"
- default book: booklist.txt copy_pdf build/redirect.html
-
- #if defined(RAWIDB)
- ## Need to copy_pdf before redirect.html in order to get the redirect right
- .ORDER: booklist.txt copy_pdf build/redirect.html common_install
- install:: booklist.txt copy_pdf build/redirect.html common_install
- #else
- install::
- @echo "warning: 'install' not supported if RAWIDB not defined"
- #endif
-
- # Branch rule for making a book out of 'compiled' sgm files, or HTML
- #elif ${DTD} != "HTML"
-
- ## We are building a standard SGML/XML book
- .ORDER: ${MASTER_SGM} _online build/.placeholder booklist.txt build/docbook.xml build/sgi_html/index.html copy_figures build/redirect.html copy_pdf
- default book review help xhelp: booklist.txt build/sgi_html/index.html figures build/redirect.html copy_pdf
-
- #if defined(RAWIDB)
- .ORDER: ${MASTER_SGM} build/.placeholder booklist.txt build/sgi_html/index.html copy_figures build/redirect.html copy_pdf common_install xmlbook_install
- install:: booklist.txt build/sgi_html/index.html copy_figures build/redirect.html xmlbook_install
- #else
- install::
- @echo "warning: 'install' not supported if RAWIDB not defined"
- #endif
-
- #else
-
- ## We are building a plain HTML book
- .ORDER: booklist.txt htmlbook build/redirect.html copy_pdf
- default book: htmlbook build/redirect.html copy_pdf
-
- review help xhelp:
- @echo "operation not supported with HTML books"
-
- clobber clean:
- ${RM} -rf build booklist.txt
-
- #if defined(RAWIDB)
- .ORDER: booklist.txt htmlbook build/redirect.html copy_pdf common_install htmlbook_install
- install: booklist.txt htmlbook build/redirect.html htmlbook_install
- #else
- install:
- @echo "warning: 'install' not supported if RAWIDB not defined"
-
- #endif
- #endif
-
- copy_pdf: _force
- #if defined(PACKAGE_PDF) && ${PACKAGE_PDF} == 1
- #if defined(PDF_FILES) && ${PDF_FILES} != ""
- @echo "=============================================="
- @echo "Copying the list of PDF_FILES"
- @echo "=============================================="
- @rm -rf build/pdf
- @mkdir -p build/pdf
- @for i in "$(PDF_FILES)"; do \
- if [ ! -e $$i ] ; then \
- echo "Couldn't find PDF_FILES '$$i'" ; \
- exit 1 ; \
- fi ; \
- cp $$i build/pdf
- done
- #elif exists(${DEFAULT_PDF})
- @echo "=============================================="
- @echo "Copying ${DEFAULT_PDF}"
- @echo "=============================================="
- @rm -rf build/pdf
- @mkdir -p build/pdf
- @cp ${DEFAULT_PDF} build/pdf/${BOOK}.pdf
- #endif
- #endif
-
- book.err ${BOOK}.err: ${ERR_FILES}
- @${RM} -f ${BOOK}.err
- @for i in ${ERR_FILES}; do \
- echo "=== $$i Translation Error/Warning report ===" >> ${BOOK}.err; \
- cat $$i >> ${BOOK}.err; \
- echo "" >> ${BOOK}.err; \
- done
-
- book.full review.full ${BOOK}.full: ${ERR_FILES} ${MASTER_SGM} book
- @echo "======================================================="
- @echo "Building master report file - ${BOOK}.full"
- @echo "======================================================="
- @${RM} -f ${BOOK}.full
- @for i in ${SGM_FILES}; do \
- base=`basename $$i .sgm`; \
- if [ -f $$base.err ] ; then \
- echo "=== $$base.err Translation Error/Warning report ===" >> ${BOOK}.full; \
- cat $$base.err >> ${BOOK}.full; \
- fi; \
- echo "" >> ${BOOK}.full; \
- done
- @echo "=== ${BOOK} Link QA report file ===" >> ${BOOK}.full
- -@(TOOLROOT=${ITOOLROOT}; export TOOLROOT; \
- ${XREF} ${MASTER_SGM} >> ${BOOK}.full)
- @echo "" >> ${BOOK}.full
-
- common_install: copy_pdf
- $(INSTALL) -u root -g sys -m 755 \
- -idb '${BOOKSUBSYSTEM} removeop("if [ -r $$rbase/usr/sbin/insightAdmin ]; then chroot \$$rbase /usr/sbin/insightAdmin -avfn ${BOOK_LANG} ${BOOKSHELF}>>\$$rbase/var/share/Insight/install.insight.log 2>&1; fi")' \
- -dir ${BOOKSHELF}/${BOOKDIR}
- # booklist.txt and redirect index.html idb
- $(INSTALL) -m 644 -f ${BOOKSHELF}/${BOOKDIR} \
- -idb '${BOOKSUBSYSTEM} exitop("(chroot \$$rbase /usr/sbin/insightAdmin -avfn ${BOOK_LANG} ${BOOKSHELF}>>\$$rbase/var/share/Insight/install.insight.log)2>>\$$rbase/var/share/Insight/install.insight.log")' \
- booklist.txt
- $(INSTALL) -m 644 -f ${BOOKSHELF}/${BOOKDIR} -idb ${BOOKSUBSYSTEM} \
- -src build/redirect.html index.html
- # sgi_data directory
- $(INSTALL) -u root -g sys -m 755 -idb ${BOOKSUBSYSTEM} \
- -dir ${BOOKSHELF}/${BOOKDIR}/sgi_data
- for i in build/sgi_data/*; do \
- $(INSTALL) -m 644 -f ${BOOKSHELF}/${BOOKDIR}/sgi_data \
- -idb ${BOOKSUBSYSTEM} \
- -src $$i `basename $$i`; done
- ## Idea to move sgi_html install to the common area
- ## for i in `cd build ; find sgi_html -type d -print`; do \
- ## $(INSTALL) -u root -g sys -m 755 -idb ${BOOKSUBSYSTEM} \
- ## -dir ${BOOKSHELF}/${BOOKDIR}/$$i ; \
- ## done
- ## for i in `cd build/sgi_html ; find * -type f -print`; do \
- ## $(INSTALL) -m 644 -f ${BOOKSHELF}/${BOOKDIR}/sgi_html \
- ## -idb ${BOOKSUBSYSTEM} -src build/sgi_html/$$i $$i ; \
- ## done
- if [ -d build/pdf ] ; then \
- $(INSTALL) -u root -g sys -m 755 -idb ${BOOKSUBSYSTEM} \
- -dir ${BOOKSHELF}/${BOOKDIR}/pdf ; \
- for i in build/pdf/*.pdf; do \
- $(INSTALL) -m 644 -f ${BOOKSHELF}/${BOOKDIR}/pdf \
- -idb ${BOOKSUBSYSTEM} \
- -src $$i `basename $$i` ; \
- done ; \
- fi
-
- xmlbook_install: common_install
- # sgi_html directory
- $(INSTALL) -u root -g sys -m 755 -idb ${BOOKSUBSYSTEM} \
- -dir ${BOOKSHELF}/${BOOKDIR}/sgi_html
- for i in build/sgi_html/*.html; do \
- $(INSTALL) -m 644 -f ${BOOKSHELF}/${BOOKDIR}/sgi_html \
- -idb ${BOOKSUBSYSTEM} \
- -src $$i `basename $$i`; done
- # sgi_html/figures directory
- if [ -d build/sgi_html/figures ] ; then \
- $(INSTALL) -u root -g sys -m 755 -idb ${BOOKSUBSYSTEM} \
- -dir ${BOOKSHELF}/${BOOKDIR}/sgi_html/figures ; \
- for i in build/sgi_html/figures/*; do \
- $(INSTALL) -m 644 -f ${BOOKSHELF}/${BOOKDIR}/sgi_html/figures \
- -idb ${BOOKSUBSYSTEM} \
- -src $$i `basename $$i` ; done ; \
- fi
- # Generate helpmap idbs
- if [ -d help ] ; then \
- if [ "${BOOK_LANG}" = "C" ] ; then \
- $(INSTALL) -m 644 -f ${HELPDIR} -idb ${HELPSUBSYSTEM} \
- `${COPY_HELPMAPS} ${MASTER_SGM} help` ; \
- else \
- for i in `${COPY_HELPMAPS} ${MASTER_SGM} help`; do \
- $(INSTALL) -m 644 -f ${HELPDIR}/help/${BOOK_LANG} \
- -idb ${HELPSUBSYSTEM} \
- -src $$i `basename $$i` ; done ; \
- fi \
- ; fi
-
- htmlbook: Makefile booklist.txt _force
- @echo "=============================================="
- @echo "Copying HTML files to build/sgi_html"
- @echo "=============================================="
- @${RM} -rf build/sgi_html
- @mkdir -p build/sgi_html build/sgi_data
- @for d in $(BOOK_DIRS); do \
- mkdir -p build/sgi_html/$$d ; \
- for ext in ${HTML_EXTS}; do \
- for f in $$d/*.$$ext; do \
- if [ -f $$f ]; then \
- ${CP} $$f build/sgi_html/$$d; \
- fi; \
- done; \
- done; \
- done
- @echo " "
- @echo "For review:"
- @if [ -f build/sgi_html/index.html ] ; then \
- echo "file://`pwd`/build/sgi_html/index.html" ; \
- else \
- echo "file://`pwd`/build/sgi_html/" ; \
- fi
- @echo " "
-
- htmlbook_install: common_install
- # Generate the sgi_html directory
- $(INSTALL) -u root -g sys -m 755 -idb ${BOOKSUBSYSTEM} \
- -dir ${BOOKSHELF}/${BOOKDIR}/sgi_html
- # Generate subdirectory idbs, if any
- for d in $(BOOK_DIRS); do \
- if [ "$$d" != "." ]; then \
- $(INSTALL) -m 755 -idb $(BOOKSUBSYSTEM) \
- -dir ${BOOKSHELF}/${BOOKDIR}/sgi_html/$$d; \
- fi; \
- done
- # Generate files idbs
- for d in $(BOOK_DIRS); do \
- if [ "$$d" = "." ]; then \
- for ext in ${HTML_EXTS}; do \
- for f in build/sgi_html/*.$$ext; do \
- if [ -e $$f ]; then \
- $(INSTALL) -m 644 -f ${BOOKSHELF}/${BOOKDIR}/sgi_html \
- -idb ${BOOKSUBSYSTEM} \
- -src $$f `basename $$f`; \
- fi ; \
- done; \
- done; \
- else \
- for ext in ${HTML_EXTS}; do \
- for f in build/sgi_html/$$d/*.$$ext; do \
- if [ -e $$f ]; then \
- $(INSTALL) -m 644 -f ${BOOKSHELF}/${BOOKDIR}/sgi_html/$$d \
- -idb ${BOOKSUBSYSTEM} \
- -src $$f `basename $$f`; \
- fi ; \
- done; \
- done; \
- fi; \
- done
- # Generate helpmap idbs
- if [ -d help ] ; then \
- (cd help; \
- if [ "${BOOK_LANG}" = "C" ] ; then \
- $(INSTALL) -m 644 -idb $(HELPSUBSYSTEM) \
- -f ${HELPDIR}/help *.helpmap; \
- else \
- $(INSTALL) -m 644 -idb $(HELPSUBSYSTEM) \
- -f ${HELPDIR}/help/${BOOK_LANG} *.helpmap; \
- fi; \
- cd ..); \
- fi
-
- ##############################################################
- #
- # Section #7 - Clean up rules
- #
- ##############################################################
-
- #if ${DTD} != "HTML"
- #if exists($(ROOT)/usr/include/make/commonindexdefs)
- .ORDER: clean_book clean_reports clean_backups sg_index_clean
- clean:: clean_book clean_reports clean_backups sg_index_clean
- #else
- .ORDER: clean_book clean_reports clean_backups
- clean:: clean_book clean_reports clean_backups
- #endif
- ${RM} -rf $(DIRT) ${LOCALFIGRULES}
-
- .ORDER: clean clean_online clean_sgm clean_print
- clobber:: clean clean_online clean_sgm clean_print
- #endif
-
- # Remove the master sgml file and files in the 'books' sub directory.
- # Also now remove tmp_gen with generated html files
- clean_book::
- ${RM} -f ${MASTER_SGM} ${INDEXFILE} ${MIF_FILES}
- ${RM} -rf build
-
- # Remove the report files
- #if defined(BOOK_FILES) && ${BOOK_FILES} == "book.sgm"
- clean_reports::
- ${RM} -f ${BOOK}.full
- #else
- clean_reports::
- ${RM} -f ${ERR_FILES} ${BOOK}.err ${BOOK}.full
- #endif
-
-
- # Remove the generated figures
- #if ${AUTO_FIGURES} == 1
- clean_online::
- ${UPDATE_FIGURES} -v clobber
-
- clean_print::
-
- #else
-
- clean_online::
- ${RM} -f online/*
-
- clean_print::
- ${RM} -f print/*
- #endif
-
- #if defined(BOOK_FILES)
- # Remove all sgml files - only if NONE of the sources are .sgm files
- #if ${BOOK_FILES:S/[ ]*/ /g} == "${BOOK_FILES:S/.sgm$/.skip/g}"
- clean_sgm::
- ${RM} -f ${SGM_FILES}
- #else
- clean_sgm::
-
- #endif
- #endif
-
- # Remove Frame backup files
- #if defined(BOOK_FILES) && ${BOOK_FILES} == "book.sgm"
- clean_backups::
- #else
- clean_backups::
- ${RM} -f ${BACKUP_FILES}
- #endif
-
- #if exists($(ROOT)/usr/include/make/commonindexdefs)
- $(INDEXPREF)sg_index_clean::
- -@/usr/bin/rm -f $(IDIRT)
- #if defined(SRC)
- -@/usr/bin/rm -f $(WORDDIR)/$(IDIRT)
- #endif
- #endif
-
- # Remove any crufty files
- XDIRT = printFiles.* onlineFiles.* localFigs.* ${DIRT_FILES} ${BOOK}.sgml.tmp \
- *.bak *.backup booklist.txt.old EndPart.err EndPart
-
- ##############################################################
- #
- # Section #8 - Figure rules
- #
- ##############################################################
-
- ##.ORDER: _online copy_figures
- figures: _online copy_figures
-
- #if ${AUTO_FIGURES} == 1
- localfigrules:
- #else
- localfigrules: Makefile
- @smake -J 1 -r -f Makefile XXX=$$$$ rules
- #endif
-
- #if ${AUTO_FIGURES} == 1
- _online:
- #if make(_online)
- ## Run verbosely if _online is the direct target
- @${UPDATE_FIGURES} -v
- #else
- @${UPDATE_FIGURES}
- #endif
- #else
- _online: localfigrules
- @if [ -d orig ] ; then \
- (mkdir -p online 1> /dev/null 2>&1; \
- TOOLROOT=${ITOOLROOT}; export TOOLROOT; \
- make -r -f Makefile COMMONPREPRULES=${COMMONFIGRULES} online_figs) ;\
- fi
- #endif
-
- #if ${AUTO_FIGURES} == 1
- _print print:
- @${UPDATE_FIGURES} -v
- #else
- _print print: localfigrules
- -@mkdir -p print 1> /dev/null 2>&1
- @make -r -f Makefile COMMONPREPRULES=${COMMONFIGRULES} print_figs
- #endif
-
- copy_figures: build/sgi_html/index.html build/.placeholder _force
- @echo "=============================================="
- @echo "Copying figures into the html directory"
- @echo "=============================================="
- @mkdir -p build/sgi_html/figures
- -@if [ -d online ] ; then \
- (for i in build/sgi_html/figures/*; do \
- ${RM} -f $$i ; done ) ; \
- fi
- #if ${DTD} == "SGIDOCBK" || ${DTD} == "SGIDOC"
- @if [ -d online -a -e ${MASTER_SGM} ] ; then \
- ${CLEAN_CGMS} ${MASTER_SGM} online ; \
- fi
- #endif
- @${COPY_DOCBOOK_FIGS} build/sgi_html/*.html
- #if defined(MISC_FILES)
- #if ! empty(MISC_FILES)
- @for i in ${MISC_FILES} ; do \
- if [ -e orig/$$i ] ; then \
- cp orig/$$i build/sgi_html/figures ; \
- elif [ -e online/$$i ] ; then \
- cp online/$$i build/sgi_html/figures ; \
- else \
- echo "Couldn't locate MISC_FILES '$$i'" ; \
- exit 1; \
- fi ; \
- done ;
- ## @(cd orig; ${CP} ${MISC_FILES} ../build/sgi_html/figures ; cd ..)
- #endif
- #endif
- @( cd build/sgi_html ; ${HTML_IMG_SIZE} *.html )
- ## Silently and correctly fails if any files are in the figure directory
- -@rmdir build/sgi_html/figures 1> /dev/null 2>&1
-
- ##############################################################
- #
- # Section #9 - Misc. rules
- #
- ##############################################################
-
- update_frontmatter:
- @if [ -d ${FRONT_DIR} ] ; then \
- echo "Updating the frontmatter directory" ; \
- mkdir -p frontmatter ; \
- cp ${FRONT_DIR}/*.sgml frontmatter ; \
- else \
- echo "WARNING: The directory ${FRONT_DIR}" ; \
- echo "is not accessable therefore we can not update the frontmatter." ; \
- fi
-
- html.tar: book
- rm -rf build/html html.tar
- mv build/sgi_html build/html
- (cd build ; tar -cvf ../html.tar html)
- mv build/html build/sgi_html
-